package cn.edu.bupt.scidata.utils;

/**
 * 自定义全局响应体
 */
public class CustomResponse {

    // 响应状态
    private Integer status;
    // 响应消息
    private String msg;
    // 响应体数据
    private Object data;
    private String ok;

    public CustomResponse(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public CustomResponse(Object data) {
        this.status = 200;
        this.msg = "OK";
        this.data = data;
    }

    public CustomResponse() {
        this.status = 200;
        this.msg = "OK";
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getOk() {
        return ok;
    }

    public void setOk(String ok) {
        this.ok = ok;
    }

    public static CustomResponse build(Integer status, String msg, Object data) {
        return new CustomResponse(status, msg, data);
    }

    public static CustomResponse ok(Object data) {
        return new CustomResponse(data);
    }

    public static CustomResponse ok() {
        return new CustomResponse();
    }

    public static CustomResponse errorMsg(String msg) {
        return new CustomResponse(500, msg, null);
    }
}
